PROJECTENGRAM

ARITHMETIC OPERATIONS IN BINARY

7.0 Arithmetic Operations in Binary

Tags: #◇Computer Science #◇CCICOMP #◇Problem Solving #◇M2


◇Overview

Arithmetic operations (addition, subtraction, multiplication, and division) form the core of computer processing. In order for arithmetic operations to be performed by a computer, all operands must be converted to the same base (binary). When working with signed integer data, the arithmetic logic varies depending on the specific representation scheme used (e.g., 1's complement vs. 2's complement). Specifically, how a final carry-out bit is handled distinguishes 1's complement addition from 2's complement addition. Furthermore, subtraction is universally handled by negating the subtrahend (complementing it) and then performing addition.

◇Important Formulas

Basic Binary Arithmetic Rules Binary Addition:

0+0=00 + 0 = 0
0+1=10 + 1 = 1
1+0=11 + 0 = 1
1+1=0 carry 11 + 1 = 0 \text{ carry } 1 Binary Subtraction:
0−0=00 - 0 = 0
1−0=11 - 0 = 1
1−1=01 - 1 = 0
0−1=1 borrow 10 - 1 = 1 \text{ borrow } 1 (equivalent to borrowing 22 from the next higher significance column)

Signed Integer Addition & Subtraction 1's Complement Addition: Add the two binary strings. If there is a final carry-out bit beyond the most significant bit, add that 11 back into the intermediate result (end-around carry). 2's Complement Addition: Add the two binary strings. If there is a final carry-out bit, simply discard it. Subtraction (A−BA - B): Negate the subtrahend (BB) to its complement equivalent (−B-B) using the appropriate complement rules, and then perform addition: A+(−B)A + (-B).

◇Worked Examples

1. Basic Binary Addition & Subtraction Addition: 11002+101021100_2 + 1010_2

11001100
+1010+ 1010
=101102= 10110_2 (with a carry on the final bit) Subtraction: 11002−101021100_2 - 1010_2
11001100
−1010- 1010
=00102= 0010_2

2. 1's Complement Addition

Add +6+6 and −2-2 using 88-bit 1's complement strings. +6=000001102+6 = 00000110_2 −2=111111012-2 = 11111101_2 Add them: 000001102+111111012=100000011200000110_2 + 11111101_2 = 1 00000011_2 (carry out is 11) End-around carry (add 11 to result): 000000112+12=00000100200000011_2 + 1_2 = 00000100_2 Result: 000001002=+41000000100_2 = +4_{10}

3. 2's Complement Addition

Add −6-6 and −2-2 using 88-bit 2's complement strings. −6=111110102-6 = 11111010_2 −2=111111102-2 = 11111110_2 Add them: 111110102+111111102=111111000211111010_2 + 11111110_2 = 1 11111000_2 (carry out is 11) Discard the final carry out: 11111000211111000_2 Result: 111110002=−81011111000_2 = -8_{10}

4. 2's Complement Subtraction

Perform (+2)−(+6)(+2) - (+6) using 88-bit 2's complement strings. Equivalent to (+2)+(−6)(+2) + (-6). +2=000000102+2 = 00000010_2 +6=000001102  ⟹  −6=111110102+6 = 00000110_2 \implies -6 = 11111010_2 (Invert bits and add 11) Add them: 000000102+111110102=11111100200000010_2 + 11111010_2 = 11111100_2 Result is negative. Invert and add 11 to check value: 000000112+1=000001002=400000011_2 + 1 = 00000100_2 = 4. So, −410-4_{10}.

◇References & Navigation

CONFIRMATION // 理解度の確認

ACTIVE RECALL VERIFICATION

Select an answer to verify conceptual comprehension and reveal the technical rationale.

Q1

In binary arithmetic, what is the result of adding 1 and 1?

Q2

How is subtraction (A - B) universally handled in binary logic?

Q3

When performing 1's complement addition, what must be done if there is a final carry-out bit beyond the most significant bit?

Q4

In binary subtraction, what is the result of subtracting 1 from 0 (0 - 1)?

Q5

What is the correct protocol for a final carry-out bit in 2's complement addition?

Q6

To calculate 1's complement representation, how is a positive number converted to a negative number?

Q7

What is the sum of 1100 and 1010 in basic binary addition?

Q8

When an arithmetic operation must be performed on signed integer data, what requirement must be met for the operands?

Q9

In a 2's complement subtraction resulting in a negative value, how can the magnitude of the result be checked?

Q10

What distinguishes 1's complement arithmetic from 2's complement arithmetic during addition?